package com.xbongbong.pro.statistic.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author guohui.zhang
 * @Title: 线索转化阶段枚举
 * @date 2020/12/711:29
 */
@Getter
public enum  CLueConversionStageEnum {

    CLUE(1,"clue","enum.clueConversionStageEnum.name.clue", "enum.clueConversionStageEnum.names.clue", XbbRefTypeEnum.CLUE),
    CUSTOMER(2,"customer","enum.clueConversionStageEnum.name.customer","enum.clueConversionStageEnum.names.customer", XbbRefTypeEnum.CUSTOMER),
    OPPORTUNITY(3,"opportunity","enum.clueConversionStageEnum.name.opportunity", "enum.clueConversionStageEnum.names.opportunity", XbbRefTypeEnum.SALES_OPPORTUNITY),
    WIN_OPPORTUNITY(4,"win_opportunity","enum.clueConversionStageEnum.name.win_opportunity", "enum.clueConversionStageEnum.names.win_opportunity", XbbRefTypeEnum.SALES_OPPORTUNITY),
    SUCCESS_ORDER(5,"success_order","enum.clueConversionStageEnum.name.success_order", "enum.clueConversionStageEnum.names.success_order", XbbRefTypeEnum.CONTRACT),
    ;

    private Integer code;

    private String alias;

    private String name;

    /**
     * 漏斗前缀
     */
    private String names;

    private XbbRefTypeEnum xbbRefTypeEnum;

    CLueConversionStageEnum(Integer code, String alias, String name, String names, XbbRefTypeEnum xbbRefTypeEnum) {
        this.code = code;
        this.alias = alias;
        this.name = name;
        this.names = names;
        this.xbbRefTypeEnum = xbbRefTypeEnum;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public String getNames() {
        return I18nMessageUtil.getMessage(names);
    }

    public static CLueConversionStageEnum getByAlias(Integer code) {
        for (CLueConversionStageEnum cacheCode : values()) {
            if (cacheCode.getCode().equals(code)) {
                return cacheCode;
            }
        }
        return null;
    }

    public static List<CLueConversionStageEnum> getAllEnum() {
        List<CLueConversionStageEnum> list = new ArrayList<>();
        for (CLueConversionStageEnum cache : values()) {
            list.add(cache);
        }
        return list;
    }
}
